
#region Using Statements
using System;
using System.Collections.Generic;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

using Elephant.Utility.Components;

using Elephant.Framework;
using Elephant.Framework.Services;

namespace SpinningPyramid
{
    [ComponentDependency(typeof(Transform))]
    public class Spinner : EntityComponent
    {
        Transform transform;

        float a, speed = 2;

        public override void Initialize(bool addDependencies)
        {
            base.Initialize(addDependencies);
            
            transform = Owner.Find<Transform>();
        }

        public override void Update(GameTime gameTime)
        {
            a += speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

            transform.Orientation = Quaternion.CreateFromYawPitchRoll(
                a,
                a * 2,
                a * 2 / (float)Math.PI);
        }

        public float Speed
        {
            get
            {
                return speed;
            }
            set
            {
                speed = value;
            }
        }
    }
}
